<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
  <script>
      // var  rexp=/^[0-9a-zA-Z]{3,}@[0-9a-zA-Z]{2,}[.](com|net|cn)$/;
      // var x="123111dse@qq.com"
      // //判断字符串是否匹配正则表达式
      // console.log(rexp.test(x))
    function checkName(){
        var rexp=/^[a-zA-Z\u4e00-\u9fa5]{2,}$/
        if (rexp.test($("userName").value)){
            $("nameSpan").innerHTML="验证通过";
            $("nameSpan").style.color="green";
        }else {
            $("nameSpan").innerHTML="姓名必须为两位数以上的数字或者字母";
            $("nameSpan").style.color="red";
        }
    }
    function $(id){
        return document.getElementById(id);
    }
  </script>
</head>
<body>
<form action="add">
    姓名：<input type="text" name="userName" id="userName" onblur="checkName()">
    <spanm id="nameSpan"></spanm><br>
</form>

</body>
</html>